﻿@model TopMenuModel
@using Nop.Core.Domain
@using Nop.Core.Infrastructure
@using Nop.Web.Models.Catalog;

@helper RenderCategoryLine(CategorySimpleModel category, int level)
{
    @*Url.RouteUrl("Category", new { SeName = category.SeName })*@
    <li>
        <a href="/@category.SeName">@category.Name
        @if (category.NumberOfProducts.HasValue)
        {
            <text> </text>@T("Categories.TotalProducts", category.NumberOfProducts.Value)
        }
        </a>
        @{
            var levelClass = "";
            if (level == 0)
            {
                levelClass = "firstLevel";
            }
            if (category.SubCategories.Count > 0)
            {
                <div class="menu-sublist-wrapper">
                    <div class="menu-arrow-wrapper"><div class="menu-arrow" style="display: none;"></div></div>
                    <ul class="sublist @levelClass">
                        @foreach (var subCategory in  category.SubCategories)
                        {
                            @RenderCategoryLine(subCategory, level + 1)
                        }
                    </ul>
                </div>
            }
        }
    </li>
}
<ul class="category-top-menu nav navbar-nav">
    @Html.Widget("header_menu_before")
    @if (Model.Categories.Count > 0)
    {
        foreach (var category in Model.Categories)
        {
            @RenderCategoryLine(category, 0)
        }
    }
    else
    {
    }
    @Html.Widget("header_menu_after")
</ul>